package com.ruoyi.web.controller.application;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.XxkApplicationInterface;
import com.ruoyi.system.service.IXxkApplicationInterfaceService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用接口管理Controller
 * 
 * @author ruoyi
 * @date 2025-04-04
 */
@Controller
@RequestMapping("/system/interface")
public class XxkApplicationInterfaceController extends BaseController
{
    private String prefix = "system/interface";

    @Autowired
    private IXxkApplicationInterfaceService xxkApplicationInterfaceService;

    @RequiresPermissions("system:interface:view")
    @GetMapping()
    public String appInterface()
    {
        return prefix + "/interface";
    }

    /**
     * 查询应用接口管理列表
     */
    @RequiresPermissions("system:interface:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(XxkApplicationInterface xxkApplicationInterface)
    {
        startPage();
        List<XxkApplicationInterface> list = xxkApplicationInterfaceService.selectXxkApplicationInterfaceList(xxkApplicationInterface);
        return getDataTable(list);
    }

    /**
     * 导出应用接口管理列表
     */
    @RequiresPermissions("system:interface:export")
    @Log(title = "应用接口管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(XxkApplicationInterface xxkApplicationInterface)
    {
        List<XxkApplicationInterface> list = xxkApplicationInterfaceService.selectXxkApplicationInterfaceList(xxkApplicationInterface);
        ExcelUtil<XxkApplicationInterface> util = new ExcelUtil<XxkApplicationInterface>(XxkApplicationInterface.class);
        return util.exportExcel(list, "应用接口管理数据");
    }

    /**
     * 新增应用接口管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存应用接口管理
     */
    @RequiresPermissions("system:interface:add")
    @Log(title = "应用接口管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(XxkApplicationInterface xxkApplicationInterface)
    {
        return toAjax(xxkApplicationInterfaceService.insertXxkApplicationInterface(xxkApplicationInterface));
    }

    /**
     * 修改应用接口管理
     */
    @RequiresPermissions("system:interface:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        XxkApplicationInterface xxkApplicationInterface = xxkApplicationInterfaceService.selectXxkApplicationInterfaceById(id);
        mmap.put("xxkApplicationInterface", xxkApplicationInterface);
        return prefix + "/edit";
    }

    /**
     * 修改保存应用接口管理
     */
    @RequiresPermissions("system:interface:edit")
    @Log(title = "应用接口管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(XxkApplicationInterface xxkApplicationInterface)
    {
        return toAjax(xxkApplicationInterfaceService.updateXxkApplicationInterface(xxkApplicationInterface));
    }

    /**
     * 删除应用接口管理
     */
    @RequiresPermissions("system:interface:remove")
    @Log(title = "应用接口管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(xxkApplicationInterfaceService.deleteXxkApplicationInterfaceByIds(ids));
    }
}
